

package cn.shengchao.examstar.distributor.gateway.controller;

import cn.shengchao.examstar.distributor.gateway.controller.query.OrderPageQuery;
import cn.shengchao.examstar.distributor.gateway.controller.query.OrderQuery;
import cn.shengchao.examstar.distributor.gateway.service.DistributorService;
import cn.shengchao.examstar.distributor.gateway.service.message.DistributorOrder;
import cn.shengchao.examstar.distributor.gateway.service.message.DistributorOrderStatistics;
import cn.shengchao.examstar.rpc.base.PageResult;
import cn.shengchao.util.helper.LoginHelper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@CrossOrigin("${project.cross-origin}")
@RequestMapping("/api/${project.version}/distributor/order")
public class DistributorOrderController {

    @Autowired
    private DistributorService distributorService;
    /**
     * 获取订单列表
     */
    @GetMapping("page")
    public PageResult<DistributorOrder> getOrders(OrderPageQuery orderPageQuery) {
        return distributorService.getOrderPage(LoginHelper.getUserId(), orderPageQuery);
    }

    /**
     * 获取订单列表
     */
    @GetMapping
    public List<DistributorOrder> getOrders(OrderQuery orderQuery) {
        return distributorService.getOrderList(LoginHelper.getUserId(), orderQuery);
    }

    /**
     * 获取订单统计信息
     */
    @GetMapping("/statistics")
    public DistributorOrderStatistics getOrderStatistics() {
        return distributorService.getOrderStatistics(LoginHelper.getUserId());
    }
}
